package org.learning;

public class A_03 {
    private static class MyClass {

        private static final Object guardian = new Object();

        public synchronized void methodA1() {
            System.out.println("methodA1");
        }

        public void methodA2() {
            synchronized (this) {
                System.out.println("methodA2");
            }
        }

        public static synchronized void methodB1() {
            System.out.println("method2");
        }

        public static void methodB2() {
            synchronized (MyClass.class) {
                System.out.println("methodB2");
            }
        }

        public void methodC1() {
            synchronized (guardian) {
                System.out.println("methodC1");
            }
        }
    }

    public static void main(String[] args) {
        MyClass myClass = new MyClass();
        myClass.methodA1();
        myClass.methodA2();
        MyClass.methodB1();
        MyClass.methodB2();
        myClass.methodC1();
    }
}
